package com.chen.user.controller;


import com.chen.user.common.Result;
import com.chen.user.entity.HotelBooking;
import com.chen.user.entity.Reservation;
import com.chen.user.service.ResverService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class ResverController {


    @Autowired
    private ResverService resverService;


   @GetMapping("/getBookingOrderInfoPage")
   public Result<PageInfo> getBookingOrderInfoPage(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize)
   {
       PageHelper.startPage(pageNum,pageSize);
      List<HotelBooking> hotelBookingList= resverService.getBookingOrderInfoPage();
      return Result.success(PageInfo.of(hotelBookingList));
   }


    /**
     * 查看个人订单
     * @param reservation
     * @return
     */
    @GetMapping("/getOrderInfoById")
    public Result getOrderInfoById(@RequestBody Reservation reservation) {
        int id = reservation.getId();
        Reservation resverServiceSelectById = resverService.getSelectById(id);
        return Result.success(resverServiceSelectById);
    }



}
